import {Injectable} from "@angular/core";
import {PageLink} from "@app/shared/models/PageLink";
import {HttpClient, HttpParams} from "@angular/common/http";
import {catchError, Observable, tap} from "rxjs";
import HttpUtil, {RequestConfig} from "@core/http/HttpUtil";

@Injectable(
  {
    providedIn: 'root'
  }
)
export default class DeviceService {
  constructor(public http: HttpClient) {
  }

  getTenantDeviceInfos(pageLink: PageLink, type: string = '',
                       config?: RequestConfig): Observable<any> {
    return this.http.get(`/api/tenant/deviceInfos${pageLink.toQuery()}`, HttpUtil.defaultHttpOptionFromConfig(config)).pipe(
      tap((res: any) => {
        return res
      }),
      catchError((err: any) => {
        console.error(err)
        return err;
      })
    )
  }
}
